/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Agapo
 */
@Entity
@Table(name = "dependencia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dependencia.findAll", query = "SELECT d FROM Dependencia d"),
    @NamedQuery(name = "Dependencia.findByIdDependencia", query = "SELECT d FROM Dependencia d WHERE d.idDependencia = :idDependencia"),
    @NamedQuery(name = "Dependencia.findByDependencia", query = "SELECT d FROM Dependencia d WHERE d.dependencia = :dependencia")})
public class Dependencia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_dependencia")
    @GeneratedValue
    private Integer idDependencia;
    @Size(max = 50)
    @Column(name = "dependencia")
    private String dependencia;
    @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "idDependencia")
    private Collection<AccionEstrategica> accionEstrategicaCollection;
    @JoinColumn(name = "id_area", referencedColumnName = "id_area")
    @ManyToOne(optional = false)
    private Area idArea;

    public Dependencia() {
    }

    public Dependencia(Integer idDependencia) {
        this.idDependencia = idDependencia;
    }

    public Integer getIdDependencia() {
        return idDependencia;
    }

    public void setIdDependencia(Integer idDependencia) {
        this.idDependencia = idDependencia;
    }

    public String getDependencia() {
        return dependencia;
    }

    public void setDependencia(String dependencia) {
        this.dependencia = dependencia;
    }

    @XmlTransient
    public Collection<AccionEstrategica> getAccionEstrategicaCollection() {
        return accionEstrategicaCollection;
    }

    public void setAccionEstrategicaCollection(Collection<AccionEstrategica> accionEstrategicaCollection) {
        this.accionEstrategicaCollection = accionEstrategicaCollection;
    }

    public Area getIdArea() {
        return idArea;
    }

    public void setIdArea(Area idArea) {
        this.idArea = idArea;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDependencia != null ? idDependencia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dependencia)) {
            return false;
        }
        Dependencia other = (Dependencia) object;
        if ((this.idDependencia == null && other.idDependencia != null) || (this.idDependencia != null && !this.idDependencia.equals(other.idDependencia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Dependencia[ idDependencia=" + idDependencia + " ]";
    }
    
}
